<?php

namespace services\marketing;

use common\components\Service;
use common\helpers\CommonHelper;
use common\models\patient\Callback;

/**
 * Class RepairCallbackStatusService
 * @package services\marketing
 */
class RepairCallbackStatusService extends Service
{
    /**
     * 修复患者回访状态数据
     *
     * @return array
     */
    public static function updateCallbackStatus()
    {
        $callbackStatusAll = self::callbackStatus();
        foreach ($callbackStatusAll['new'] as $val) {
            Callback::updateAll(
                [
                    'callback_state_id' => $val['id'],
                    'callback_state' => $val['name']
                ],
                [
                    'callback_state_id' => $callbackStatusAll['old'][$val['id']],
                ]
            );
        }
        return true;
    }

    /**
     * 新老数据对应关系
     */
    public static function callbackStatus()
    {
        $old = [
            300 => [1, 8, 12, 17, 21, 25, 29, 30, 37, 41, 45, 46],
            301 => [3, 6, 10, 13, 15, 19, 23, 27, 32, 35, 39, 43, 48, 50],
            302 => [2, 7, 11, 16, 20, 24, 28, 31, 36, 40, 44, 47],
            303 => [4, 5, 9, 14, 18, 22, 26, 33, 34, 38, 42, 49],
        ];

        $new = [
            [
                'id' => 300,
                'name' => '未接通',
            ],
            [
                'id' => 301,
                'name' => '正常回访',
            ],
            [
                'id' => 302,
                'name' => '拉黑',
            ],
            [
                'id' => 303,
                'name' => '已到院',
            ],
        ];

        return ['new' => $new, 'old' => $old];
    }


}
